-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed Onboarding Challenge #103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a couple of changes
lm75bd/lm75bd.c
Outdated
errCode = i2cSendTo(devAddr, writeBuf, 1); | ||
RETURN_IF_ERROR_CODE(errCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines can be combined to just be RETURN_IF_ERROR_CODE(i2cSendTo(devAddr, writeBuf, 1);
lm75bd/lm75bd.c
Outdated
// read temperature from sensor | ||
uint8_t readBuf[2] = {0}; | ||
errCode = i2cReceiveFrom(devAddr, readBuf, 2); | ||
RETURN_IF_ERROR_CODE(errCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
lm75bd/lm75bd.c
Outdated
|
||
// set pointer register to 'temperature sensor' | ||
uint8_t writeBuf[] = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you know this should only be 1 uint8_t long, its best to explicitly initialize it to that size for readability
services/thermal_mgr/thermal_mgr.c
Outdated
@@ -42,19 +42,43 @@ void initThermalSystemManager(lm75bd_config_t *config) { | |||
} | |||
|
|||
error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) { | |||
/* Send an event to the thermal manager queue */ | |||
if (event != NULL) { | |||
if (xQueueSend(thermalMgrQueueHandle, (void *) event, (TickType_t) 0) == pdPASS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure that the queue has already been created
services/thermal_mgr/thermal_mgr.c
Outdated
|
||
|
||
float temp; | ||
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
receive and check the event first before reading temp, since right now even if you don't receive a measure temp command you'll be reading the temperature
services/thermal_mgr/thermal_mgr.c
Outdated
} | ||
|
||
static void thermalMgr(void *pvParameters) { | ||
/* Implement this task */ | ||
thermal_mgr_event_t eventBuf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general try to limit the scope of your variables to the smallest scope possible, so move this into the while block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 more quick changes
if (xQueueReceive(thermalMgrQueueHandle, &eventBuf, 10) == pdPASS) { | ||
if (eventBuf.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) { | ||
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp); | ||
if (errCode == ERR_CODE_SUCCESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to log the error if it was no successful
addTemperatureTelemetry(temp); | ||
} | ||
else if (eventBuf.type == THERMAL_MGR_EVENT_INTERRUPT_CMD) { | ||
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if the function call was successful or not
…emp function call was successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more quick change other than that looks good
services/thermal_mgr/thermal_mgr.c
Outdated
|
||
return ERR_CODE_SUCCESS; | ||
return ERR_CODE_INVALID_QUEUE_MSG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the thermal mgr queue handle is null, then it makes more sense to return ERR_CODE_INVALID_STATE instead since we are in a state where we have not intitialized the queue yet and it's not related to the queue msg itself
|
||
return ERR_CODE_SUCCESS; | ||
return ERR_CODE_INVALID_QUEUE_MSG; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that when your doing multiple errror checks like this it's a lot cleaner to just use multiple if statements with early returns rather than a bunch of nested if statements. For example something like ```
if(errCodeCondition){
return ERR_CODE
}
if(otherPossibleError){
return OTHER_ERROR
}
// continue with the rest of the function knowing everything before was success without need an else statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a quick change
@@ -0,0 +1 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your integration test run looks wrong
services/thermal_mgr/thermal_mgr.c
Outdated
@@ -42,19 +42,50 @@ void initThermalSystemManager(lm75bd_config_t *config) { | |||
} | |||
|
|||
error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) { | |||
/* Send an event to the thermal manager queue */ | |||
|
|||
if (&thermalMgrQueueHandle != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be == NULL instead of !=, same for below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ill add you to the github and then you can send me your email you I can add you to the notion and you can take a look through the FW task board and let me know a couple of tasks that interest you
Purpose
Onboarding
New Changes
Implemented temperature sensor driver function, thermal management task, and OS handler.
Testing
Passed all unit and integration tests